﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter02
{
    public class MainWindowViewModel
    {
        private List<Unit> catalogues;

        public MainWindowViewModel()
        {
            catalogues = new List<Unit>();
            catalogues.Add(new Unit { Num = 1, Title = "C# 基础" });
            catalogues.Add(new Unit
            {
                Num = 2,
                Title = "第一个 C# 程序",
                ChildCatalogues = new List<Unit>
                {
                    new Unit { Num = 2.1, Title = "代码" }, 
                    new Unit { Num = 2.2, Title = "编译并运行程序" },
                    new Unit { Num = 2.3, Title = "详细介绍" },
                }
            });
            catalogues.Add(new Unit
            {
                Num = 3,
                Title = "变量",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 3.1, Title = "变量的初始化" }, 
                    new Unit { Num = 3.2, Title = "类型推断" },
                    new Unit { Num = 3.3, Title = "变量的作用域" }, 
                    new Unit { Num = 3.4, Title = "常量" }, 
                }
            });
            catalogues.Add(new Unit
            {
                Num = 4,
                Title = "预定义数据类型",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 4.1, Title = "值类型和引用类型" }, 
                    new Unit { Num = 4.2, Title = "CTS 类型" },
                    new Unit { Num = 4.3, Title = "预定义的值类型" }, 
                    new Unit { Num = 4.4, Title = "预定义的引用类型" }, 
                }
            });
            catalogues.Add(new Unit
            {
                Num = 5,
                Title = "流控制",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 4.1, Title = "条件语句" }, 
                    new Unit { Num = 4.2, Title = "CTS 循环" },
                    new Unit { Num = 4.3, Title = "转跳语句" }, 
                }
            });
            catalogues.Add(new Unit { Num = 6, Title = "枚举" });
            catalogues.Add(new Unit
            {
                Num = 7,
                Title = "名称空间",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 7.1, Title = "using 语句" }, 
                    new Unit { Num = 7.2, Title = "名称空间的别名" },
                }
            });
            catalogues.Add(new Unit
            {
                Num = 8,
                Title = "Main() 方法",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 8.1, Title = "多个 Main() 方法" }, 
                    new Unit { Num = 8.2, Title = "给 Main() 方法传递参数" },
                }
            });
            catalogues.Add(new Unit { Num = 9, Title = "有关编译 C# 文件的更多内容" });
            catalogues.Add(new Unit { Num = 10, Title = "控制台 I/O" });
            catalogues.Add(new Unit
            {
                Num = 11,
                Title = "使用注释",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 11.1, Title = "源文件中的内部注释" }, 
                    new Unit { Num = 11.2, Title = "XML 文档" },
                }
            });
            catalogues.Add(new Unit
            {
                Num = 12,
                Title = "C# 预处理器指令",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 12.1, Title = "#define 和 #undef" }, 
                    new Unit { Num = 12.2, Title = "#if、#elif、#else 和 #endif" },
                    new Unit { Num = 12.3, Title = "#warning 和 #error" },
                    new Unit { Num = 12.4, Title = "#region 和 #endregion" },
                    new Unit { Num = 12.5, Title = "#line" },
                    new Unit { Num = 12.5, Title = "#pragma" },
                }
            });
            catalogues.Add(new Unit
            {
                Num = 13,
                Title = "C# 编程规则",
                ChildCatalogues = new List<Unit> 
                { 
                    new Unit { Num = 11.1, Title = "关于标识符的规则" }, 
                    new Unit { Num = 11.2, Title = "用法约定" },
                }
            });
            catalogues.Add(new Unit { Num = 14, Title = "小结" });
        }

        public List<Unit> Catalogues
        {
            get { return catalogues; }
        }

        public class Unit
        {
            public double Num { get; set; }
            public string Title { get; set; }
            public string Sample { get; set; }
            public List<Unit> ChildCatalogues { get; set; }
        }

        public override string ToString()
        {
            return "第02章 核心 C#";
        }
    }
}
